package com.nbicc.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName:
 * @Author: 仄言in
 * @Desctiption: (描述) mvc配置
 * @Date: 2021/5/13 9:48
 * @Version 1.0 (版本)
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * 视图控制器
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/record").setViewName("listrecord");
        registry.addViewController("/list").setViewName("list");
        registry.addViewController("/pandect").setViewName("pandect");
        registry.addViewController("/file").setViewName("files");
        registry.addViewController("/listroots").setViewName("listroot");
    }
    /**
     * 把拦截器添加进去,并实现那些拦截，那些不拦截
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                .addPathPatterns("/**").excludePathPatterns("/file","/","/user/**","/excel/**","/css/**","/js/**");
    }
}
